import { getFillingWagonMaterialOptions } from "@/api/modules/operation";

/**
 * @description:  获取search配置信息
 * @param {*} type  1 在供气瓶  2 返库气瓶  3 过期气瓶
 * @return {Array<CommonSearch.SearchOption>}
 */
export const useSearchOption = (): Array<CommonSearch.SearchOption> => {
  const transportDateStart: CommonSearch.SearchOption = {
    label: "载送日期",
    key: "transportDateStart",
    realKeys: ["transportDateStart", "transportDateEnd"],
    value: [],
    type: "daterange",
    span: 5
  };

  const material: CommonSearch.SearchOption = {
    label: "载送物质",
    key: "material",
    value: "",
    type: "select",
    axiosApi: getFillingWagonMaterialOptions,
    mapOption: ({ code: value = "", name: label = "" }) => ({ value, label }),
    placeholder: "请选择载送物质",
    span: 5
  };

  const supplier: CommonSearch.SearchOption = {
    label: "供应厂商",
    key: "supplier",
    value: "",
    type: "input",
    placeholder: "请输入供应厂商",
    span: 5
  };

  const dutyEngineer: CommonSearch.SearchOption = {
    label: "值班工程师",
    key: "dutyEngineer",
    value: "",
    type: "input",
    placeholder: "请输入值班工程师",
    span: 5
  };

  return [transportDateStart, material, supplier, dutyEngineer];
};

/**
 * @description:  获取table表格的表头（cloumns）信息
 * @param {*} type  1 在供气瓶  2 返库气瓶  3 过期气瓶
 * @return {Array<CommonTable.TableCloumnsType>}
 */
export const useTableCloumns = (): Array<CommonTable.TableCloumnsType> => {
  const o_1 = { label: "载送日期", prop: "transportDate", sortable: true };
  const o_2 = { label: "载送物质", prop: "material" };
  const o_3 = { label: "载送数量", prop: "capacity" };
  const o_4 = { label: "供应厂商", prop: "supplier" };
  const o_5 = { label: "槽车车号", prop: "tankTruckNo" };
  const o_6 = { label: "Lot Number", prop: "lotNumber" };
  const o_7 = { label: "值班工程师", prop: "dutyEngineer" };
  const o_8 = { label: "厂商工程师", prop: "supplierEngineer" };
  const o_9 = { label: "关联工单", prop: "workOrderNo" };
  const o_10 = { label: "备注", prop: "remark", width: 120 };
  return [o_1, o_2, o_3, o_4, o_5, o_6, o_7, o_8, o_9, o_10];
};
